package com.store.comstant;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;


@ApiModel(description = "分页请求对象")
public class BasePageForm {

    public final static int DEFAULT_CURRENT_PAGE = 1;
    public final static int DEFAULT_PAGE_SIZE = 10;

    @ApiModelProperty(value = "当前页数",position = 1)
    private Integer currentPage;

    @ApiModelProperty(value = "每页请求条数",position = 2)
    private Integer pageSize;

    @ApiModelProperty(value = "自定义排序",position = 3)
    private List<OrderItem> orders;

    public BasePageForm(){

    }

    public BasePageForm(Integer currentPage, Integer pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public Integer getCurrentPage() {
        if (null == currentPage || currentPage <= 0) {
            return DEFAULT_CURRENT_PAGE;
        }
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        if (null == pageSize || pageSize <= 0) {
            return DEFAULT_PAGE_SIZE;
        }
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<OrderItem> getOrders() {
        return orders;
    }

    public void setOrders(List<OrderItem> orders) {
        this.orders = orders;
    }
}
